package com.guoxin.chapter2.synchoronizedupdatenewvalue;

/**
 * @author guoxin
 * @date 2019年8月21日
 */
public class Service {
	private boolean isContinueRun = true;
	
	/**
	 * synchronized 关键字可以具有可见性
	 */
	public void runMethod(){
		Object lock = new Object();
		while(isContinueRun){
			synchronized (lock) {
				
			}
		}
		System.out.println("停下来了");
	}
	
	public void stopMethod(){
		isContinueRun = false;
	}
}
